package com.atguigu.tingshu.dispatch.job;

import com.atguigu.tingshu.search.client.SearchFeignClient;
import com.atguigu.tingshu.user.client.UserFeignClient;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DispatchHandler {

    @Resource
    private SearchFeignClient searchFeignClient;


    @Resource
    private UserFeignClient userFeignClient;

    @XxlJob("updateHotAlbumStat")
    public void updateHotAlbumStat() {
        searchFeignClient.updateLatelyAlbumRanking();
        log.info("定时更新热门专辑信息");
    }


    @XxlJob("updateVIPStat")
    public ReturnT updateVIPStat() {
        try {
            String jobParam = XxlJobHelper.getJobParam();
            log.info("定时执行会员状态:{}", jobParam);
            userFeignClient.updateVipExpireStatus();
            return ReturnT.SUCCESS;
        } catch (Exception e) {
            return ReturnT.FAIL;
        }

    }

}